import axios from '@/utils/axios';

export const page = (data) => {
    return axios.request({
        url: '/app-private/page?siteId=' + data.siteId,
        method: 'get'
    });
};

export const saveAppPrivate = (data) => {
    return axios.request({
        url: '/app-private/',
        method: 'post',
        data
    });
};

export const delAppPrivate = (id, siteId) => {
    return axios.request({
        url: '/app-private/' + id + '/' + siteId,
        method: 'delete'
    });
};

export const getAppDataTracking = (dataTrackType, siteId) => {
    return axios.request({
        url: '/app-data-tracking/page?dataTrackType=' + dataTrackType + '&siteId=' + siteId,
        method: 'get'
    });
};

export const getAppDataTrackingById = (id) => {
    return axios.request({
        url: '/app-data-tracking/' + id,
        method: 'get'
    });
};

export const updateAppDataTracking = (data) => {
    return axios.request({
        url: '/app-data-tracking/' + data.id,
        data,
        method: 'put'
    });
};

export const saveAppDataTracking = (data) => {
    return axios.request({
        url: '/app-data-tracking',
        method: 'post',
        data
    });
};

export const delAppDataTrackingById = (id, siteId) => {
    return axios.request({
        url: '/app-data-tracking/' + id + '/' + siteId,
        method: 'delete'
    });
};

export const getAppFbMessenger = (siteId) => {
    return axios.request({
        url: '/app-fb-messenger/' + siteId,
        method: 'get'
    });
};

export const addAppFbMessenger = (data) => {
    return axios.request({
        url: '/app-fb-messenger',
        method: 'post',
        data
    });
};

export const getAppFbDomain = (siteId) => {
    return axios.request({
        url: '/app-fb-domain/' + siteId,
        method: 'get'
    });
};

export const addAppFbDomain = (data) => {
    return axios.request({
        url: '/app-fb-domain',
        method: 'post',
        data
    });
};

// 新增tiktok-pixel
export const addTiktokPixel = (data) => {
    return axios.request({
        url: '/app-data-tracking/tk/',
        method: 'post',
        data
    });
};
// 编辑tilktokpixel
export const updateTiktokPixel = (data) => {
    return axios.request({
        url: '/app-data-tracking/tk/',
        data,
        method: 'put'
    });
};
// 分页查询tiktok_ pixel
export const getTiktokPixel = (params) => {
    return axios.request({
        url: '/app-data-tracking/tk/page',
        method: 'get',
        params
    });
};
// 编辑tiktok_ pixel开启状态
export const updateTiktokPixelStatus = (id) => {
    return axios.request({
        url: '/app-data-tracking/tk/updateState',
        data: {id},
        method: 'put'
    });
};
// 删除站点tiktok_ pixel
export const delTiktokPixel = (id, siteId) => {
    return axios.request({
        url: `/app-data-tracking/tk/${siteId}/${id}`,
        method: 'delete'
    });
};

// 捆绑列表分页
export const getTiedUpList = (params) => {
    return axios.request({
        url: '/bundle-sale/page',
        method: 'get',
        params
    });
};

// 获取捆绑详情
export const getTiedUpDetail = (id) => {
    return axios.request({
        url: `/bundle-sale/${id}`,
        method: 'get'
    });
};

// 新增捆绑
export const addTiedUp = (data) => {
    return axios.request({
        url: '/bundle-sale',
        method: 'post',
        data
    });
};

// 修改捆绑
export const updateTiedUp = (id, data) => {
    return axios.request({
        url: `/bundle-sale/${id}`,
        data,
        method: 'put'
    });
};

// 删除站点tiktok_ pixel
export const delTiedUp = (id, siteId) => {
    return axios.request({
        url: `/bundle-sale/${id}`,
        method: 'delete'
    });
};

// 获取站点的Google Ads配置
export const googleAdsConfig = (siteId) => {
    return axios.request({
        url: `/google-config/${siteId}/ads`,
        method: 'get'
    });
};
// 获取Google配置项
export const googleAds = (siteId) => {
    return axios.request({
        url: `/google-config/${siteId}`,
        method: 'get'
    });
};
// 新增Google配置项
export const addGoogleAds = (data) => {
    return axios.request({
        url: '/google-config',
        method: 'post',
        data
    });
};
// 配置GoogleAds的转化标签
export const updateGoogleAds = (id, data) => {
    return axios.request({
        url: `/google-config/ads-detail/${id}`,
        data,
        method: 'put'
    });
};
// 下载google feed数据
export const exportFeed = (siteId) => {
    return axios.request({
        url: `google-config/${siteId}/export-feed`,
        method: 'get'
    });
};

// 关联fb账户
export const addFbReTracking = (data) => {
    return axios.request({
        url: '/fb-assistant',
        method: 'post',
        data
    });
};

// 获取fb辅助工具绑定列表
export const fbReTrackingList = (params) => {
    return axios.request({
        url: '/fb-assistant/list',
        params,
        method: 'get'
    });
};

// 删除fb辅助工具账户
export const delReTracking = (id) => {
    return axios.request({
        url: `/fb-assistant/${id}`,
        method: 'delete'
    });
};
